$(function () {
    //表格初始加载
    $('#grid_czrz').datagrid({
        url:$.webPath() + "/xtgl/czrz/czrzList",
        toolbar:"#toolbar_czrz",
        fitColumns:true,
        singleSelect:true,
        pagination:true,
        pageNumber:1,
        fit:true,
        rownumbers:true,
        striped:true,
        columns:[[
            {field:'yh_xm', title:'用户姓名', width:50},
            {field:'yh_zgjg_qc', title:'主管机构', width:100},
            {field:'dlip', title:'IP地址', width:100},
            {field:'dlmac', title:'MAC地址', width:100},
            {field:'cznr', title:'操作内容', width:400},
            {field:'czrq_time', title:'操作时间', width:100}
        ]],
        onDblClickCell:function (rowIndex, field, value) {
            if (field == "yh_xm")
                czrz_ViewItem("详细信息");
        }
    });
    //**********按钮触发事件**********
    //查询按钮
    $("#btn_czrz_search").click(function () {
        czrz_search();
    });
});



function czrz_ViewItem(title) {
    var record = $('#grid_czrz').datagrid('getSelected');
    if (record == null) {
        $.messager.alert("提示", "请选择要展示的记录!", "info");
        return;
    }
    var href = $.webPath() + "/xtgl/czrz/czrz_view?czrzId="+record.id;
    showCzrzViewDialog(title, href);
}

function showCzrzViewDialog(title, href) {
    var win = $.window({
        onBeforeClose: function () {
            $(".validatebox-tip").remove();
        },
        title: title,
        width: 550,
        height: 390,
        cache: false,
        url: href,
        modal: true
    });
}

//查询登录日志
function czrz_search() {
    $('#grid_czrz').datagrid('reload', {
        czrq:$("#toolbar_czrz #czrz_czrq").datebox("getValue") || '',
        yhXm:$("#toolbar_czrz #czrz_yh").val()
    });
}